package com.mb.app.controller;

import com.mb.app.domain.TbChannelConfig;
import com.mb.app.domain.TbUserInfo;
import com.mb.app.domain.TbUserInfoImage;
import com.mb.app.service.ITbChannelConfigService;
import com.mb.app.service.ITbUserInfoImageService;
import com.mb.app.service.ITbUserInfoService;
import com.mb.common.controller.BaseController;
import com.mb.common.utils.DateUtils;
import com.mb.common.utils.PageUtils;
import com.mb.common.utils.Query;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author zwl
 * @program
 * @description 用户查询管理
 * @date 2019-03-21 16:58
 **/
@Controller
@RequestMapping("/app/userQuery")
@Slf4j
public class UserQueryController extends BaseController {

    @Autowired
    private ITbUserInfoImageService userInfoImageService;


    @GetMapping("/index")
    String index(){
        return "/app/userQuery/userQuery_list";
    }


    @ResponseBody
    @GetMapping("/list")
    public PageUtils list(@RequestParam Map<String, Object> params) {
        // 查询列表数据
        // 时间截取
        String regTime = (String) params.get("regTime");
        if (StringUtils.isNotEmpty(regTime)) {
            params.put("startTime", DateUtils.parse(regTime.substring(0,10),DateUtils.DATE_PATTERN));
            params.put("endTime",regTime.substring(13,23)+" 23:59:59");
        }
        params.put("userId",getUserId());
        Query query = new Query(params);
        List<TbUserInfoImage> list = userInfoImageService.queryListChannel(query);
        int total = userInfoImageService.countChannel(query);
        PageUtils pageUtils = new PageUtils(list, total);
        return pageUtils;
    }


}
